
# print('########### 变量和类型 开始 ###########')
# print(0b100)  # 二进制整数
# print(0o100)  # 八进制整数
# print(100)    # 十进制整数
# print(0x100)  # 十六进制整数
#
# print(123.456)  # 数学写法
# print(1.23456e2)  # 科学计数法
#
# a = 45        # 定义变量a，赋值45
# b = 12        # 定义变量b，赋值12
# print(a, b)   # 45 12
# print(a + b)  # 57
# print(a - b)  # 33
# print(a * b)  # 540
# print(a / b)  # 3.75
#
# a = 100
# b = 123.45
# c = 'hello, world'
# d = True
# print(type(a))  # <class 'int'>
# print(type(b))  # <class 'float'>
# print(type(c))  # <class 'str'>
# print(type(d))  # <class 'bool'>
#
# a = 100
# b = 123.45
# c = '123'
# d = '100'
# e = '123.45'
# f = 'hello, world'
# g = True
# print(float(a))         # int类型的100转成float，输出100.0
# print(int(b))           # float类型的123.45转成int，输出123
# print(int(c))           # str类型的'123'转成int，输出123
# print(int(c, base=16))  # str类型的'123'按十六进制转成int，输出291
# print(int(d, base=2))   # str类型的'100'按二进制转成int，输出4
# print(float(e))         # str类型的'123.45'转成float，输出123.45
# print(bool(f))          # str类型的'hello, world'转成bool，输出True
# print(int(g))           # bool类型的True转成int，输出1
# print(chr(a))           # int类型的100转成str，输出'd'
# print(ord('d'))         # str类型的'd'转成int，输出100
# print('########### 变量和类型 结束 ###########')

# print('########### 运算符 开始 ###########')
# # | 运算符                                                       | 描述                           |
# # | ------------------------------------------------------------ | ------------------------------ |
# # | `[]`、`[:]`                                                 | 索引、切片                  |
# # | `**`                                                         | 幂                             |
# # | `~`、`+`、`-`                                              | 按位取反、正号、负号         |
# # | `*`、`/`、`%`、`//`                                       | 乘、除、模、整除            |
# # | `+`、`-`                                                    | 加、减                        |
# # | `>>`、`<<`                                                  | 右移、左移                    |
# # | `&`                                                          | 按位与                         |
# # | `^`、`|`                                                   | 按位异或、按位或              |
# # | `<=`、`<`、`>`、`>=`                                      | 小于等于、小于、大于、大于等于 |
# # | `==`、`!=`                                                   | 等于、不等于                  |
# # | `is`、`is not`                                               | 身份运算符                     |
# # | `in`、`not in`                                                | 成员运算符                     |
# # | `not`、`or`、`and`                                             | 逻辑运算符                     |
# # | `=`、`+=`、`-=`、`*=`、`/=`、`%=`、`//=`、`**=`、`&=`、`\|=`、`^=`、`>>=`、`<<=` | 赋值运算符             |
# print('########### 运算符 结束 ###########')

# print('########### 分支和循环 开始 ###########')
# a = float(input('a = '))
# b = float(input('b = '))
# c = float(input('c = '))
# if a + b > c and a + c > b and b + c > a:
#     perimeter = a + b + c
#     print(f'周长: {perimeter}')
#     s = perimeter / 2
#     area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
#     print(f'面积: {area}')
# else:
#     print('不能构成三角形')
#
# print('########### 分支和循环  结束 ###########')


print('########### 列表  结束 ###########')
items1 = [35, 12, 99, 68, 55, 35, 87]
items2 = ['Python', 'Java', 'Go', 'Kotlin']
items3 = [100, 12.3, 'Python', True]
print(items1)  # [35, 12, 99, 68, 55, 35, 87]
print(items2)  # ['Python', 'Java', 'Go', 'Kotlin']
print(items3)  # [100, 12.3, 'Python', True]

#Python 内置的`list`函数将其他序列变成列表
items4 = list(range(1, 10))
items5 = list('hello')
print(items4)  # [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(items5)  # ['h', 'e', 'l', 'l', 'o']

#列表运算
items5 = [35, 12, 99, 45, 66]
items6 = [45, 58, 29]
items7 = ['Python', 'Java', 'JavaScript']
print(items5 + items6)  # [35, 12, 99, 45, 66, 45, 58, 29]
print(items6 + items7)  # [45, 58, 29, 'Python', 'Java', 'JavaScript']
items5 += items6
print(items5)  # [35, 12, 99, 45, 66, 45, 58, 29]
print(items6 * 3)  # [45, 58, 29, 45, 58, 29, 45, 58, 29]
print(items7 * 2)  # ['Python', 'Java', 'JavaScript', 'Python', 'Java', 'JavaScript']
print(29 in items6)  # True
print(99 in items6)  # False
print('C++' not in items7)     # True
print('Python' not in items7)  # False

items8 = ['apple', 'waxberry', 'pitaya', 'peach', 'watermelon']
print(items8[0])   # apple
print(items8[2])   # pitaya
print(items8[4])   # watermelon
items8[2] = 'durian'
print(items8)      # ['apple', 'waxberry', 'durian', 'peach', 'watermelon']
print(items8[-5])  # 'apple'
print(items8[-4])  # 'waxberry'
print(items8[-1])  # watermelon
items8[-4] = 'strawberry'
print(items8)      # ['apple', 'strawberry', 'durian', 'peach', 'watermelon']

print(items8[1:3:1])     # ['strawberry', 'durian']
print(items8[0:3:1])     # ['apple', 'strawberry', 'durian']
print(items8[0:5:2])     # ['apple', 'durian', 'watermelon']
print(items8[-4:-2:1])   # ['strawberry', 'durian']
print(items8[-2:-6:-1])  # ['peach', 'durian', 'strawberry', 'apple']
print('########### 列表  结束 ###########')